Skip to content

feat(content-uploader): Implement cancel all retry all handlers#4577

Merged
mergify[bot] merged 4 commits into
masterfrom
implement-cancel-all-retry-all-handlers
May 28, 2026
Merged

feat(content-uploader): Implement cancel all retry all handlers#4577
mergify[bot] merged 4 commits into
masterfrom
implement-cancel-all-retry-all-handlers

Conversation

@dealwith
Copy link
Copy Markdown
Collaborator

@dealwith dealwith commented May 20, 2026

Summary

  • Implement Cancel All and Retry All for the modernized uploads manager: new handlers handleModernizedCancelAll and handleModernizedRetryAll wired to the panel's onCancelAll / onRetryAll.
  • Implement per-item Cancel and Retry: split the prior shared handleModernizedItemAction into dedicated handleModernizedItemCancel / handleModernizedItemRetry so each calls the right legacy callback (onClickCancel, onClickRetry/onClickResume) and respects status preconditions.
  • Extract markItemCanceled helper: cancels via api.cancel(), sets status to STATUS_CANCELED, fires onClickCancel. Shared by single-item and bulk cancel.
  • Add STATUS_CANCELED to constants and the 'canceled' status to the UploadStatus Flow union; extend mapToModernizedUploadItem STATUS_MAP with the canceled entry so canceled rows surface in the modernized panel.
  • Decouple UploadStatus from internal status constants — declare the union as string literals with a TODO to align with UploadItemStatus from @box/uploads-manager once the 'inprogress' value is migrated to 'uploading'.

2/5 PR in the queue:

  1. feat(uploads-manager): integrate shared feature into ContentUploader #4573
  2. 👉 feat(content-uploader): Implement cancel all retry all handlers #4577
  3. feat(content-uploader): Implement cancelled state uploads manager #4578
  4. feat(content-uploader): Implement cancel all confirmation modal #4579
  5. feat(content-uploader): Implement permission error handling uploads #4580

Summary by CodeRabbit

Release Notes

  • New Features
    • Introduced upload cancellation capability for individual uploads
    • Added bulk cancel action to cancel all pending and in-progress uploads simultaneously
    • Enabled retry functionality for both canceled and failed uploads

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

Walkthrough

This PR extends the upload system with a new STATUS_CANCELED status and modernized cancel/retry flows. It defines the constant and type, maps it for modernized uploads, adds per-item and bulk cancel/retry handler methods to ContentUploader, and wires them to UploadsManagerBP with comprehensive test coverage.

Changes

Upload cancel status and modernized retry flow

Layer / File(s) Summary
Status constant and type definition
src/constants.js, src/common/types/upload.js
Adds STATUS_CANCELED: 'canceled' constant and extends UploadStatus Flow union to include the new status alongside STATUS_PENDING, STATUS_IN_PROGRESS, STATUS_STAGED, STATUS_COMPLETE, and STATUS_ERROR.
Modernized status mapping
src/elements/content-uploader/utils/mapToModernizedUploadItem.ts, src/elements/content-uploader/utils/__tests__/mapToModernizedUploadItem.test.ts
Imports and maps legacy STATUS_CANCELED to modernized 'canceled' status string via STATUS_MAP; test extends parameterized case coverage to verify the mapping.
Cancel and retry handler methods
src/elements/content-uploader/ContentUploader.tsx
Imports STATUS_CANCELED and adds modernized helper methods: markItemCanceled (cancel single item via api.cancel and status update), handleCancelAll (cancel in-progress/pending), handleRetryAll (retry errored/canceled with resumable-chunk and name-in-use conflict handling), and retryUploadItem (per-item retry with conflict detection).
Handler wiring and UploadsManagerBP integration
src/elements/content-uploader/ContentUploader.tsx
Replaces generic modernized key-based handleModernizedItemAction/handleModernizedItemRemove with dedicated handleModernizedItemCancel, handleModernizedItemRetry, and handleModernizedItemRemove handlers; updates UploadsManagerBP props to wire onItemCancel, onItemRetry, onItemRemove, onCancelAll, and onRetryAll callbacks.
Test coverage for cancel and retry flows
src/elements/content-uploader/__tests__/ContentUploader.test.js
Imports STATUS_CANCELED and adds/expands tests for: modernized onItemCancel (cancels in-progress by calling api.cancel and setting status, no-ops for completed/missing items), modernized-id folder cancellation, onCancelAll (cancels pending/in-progress, skips completed), onRetryAll (restarts errored/canceled items, triggers resumeFile for resumable chunks, drops name-in-use conflicts), and per-item retry with conflict handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • box/box-ui-elements#4571: Adds the feature-flagged modernized UploadsManagerBP render path in ContentUploader; this PR builds on it by wiring cancel/retry/remove behavior.
  • box/box-ui-elements#4573: Introduces modernized uploads-manager integration and status mapping utilities; this PR extends those utilities to handle STATUS_CANCELED and adds the cancel/retry handlers.
  • box/box-ui-elements#4117: Handles "name-in-use" error conflicts by removing conflicting items; this PR extends that logic to cancel conflicts during retry-all flows.

Suggested labels

ready-to-merge, queued

Suggested reviewers

  • jpan-box
  • olehrybak
  • tjiang-box

Poem

🐰 A cancellation charm takes flight,
With statuses aligned just right,
Retry flows now dance with care,
Name conflicts dissolve in air,
The uploads modernize tonight! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main feature addition: implementing cancel-all and retry-all handlers for the modernized uploads manager.
Description check ✅ Passed The description includes a comprehensive summary of changes and implementation details, though it lacks the template structure about merge procedures.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch implement-cancel-all-retry-all-handlers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dealwith dealwith changed the base branch from master to integrate-shared-feature-into-content-uploader May 21, 2026 09:34
@dealwith dealwith force-pushed the integrate-shared-feature-into-content-uploader branch from b7bf9cc to 4acdc6a Compare May 25, 2026 13:50
@dealwith dealwith marked this pull request as ready for review May 26, 2026 13:58
@dealwith dealwith requested review from a team as code owners May 26, 2026 13:58
@dealwith dealwith changed the title Implement cancel all retry all handlers feat(content-uploader): Implement cancel all retry all handlers May 26, 2026
olehrybak
olehrybak previously approved these changes May 26, 2026
Copy link
Copy Markdown
Contributor

@olehrybak olehrybak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Comment thread src/common/types/upload.js
Comment thread src/elements/content-uploader/ContentUploader.tsx Outdated
Comment thread src/elements/content-uploader/ContentUploader.tsx Outdated
Comment thread src/elements/content-uploader/ContentUploader.tsx Outdated
Comment thread src/elements/content-uploader/__tests__/ContentUploader.test.js Outdated
Comment thread src/elements/content-uploader/stories/tests/ContentUploader-visual.stories.js Outdated
Comment thread src/elements/content-uploader/ContentUploader.tsx Outdated
Copy link
Copy Markdown
Collaborator

@jpan-box jpan-box left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work and thank you for splitting up this feature into different pr, but there are some conventions that we really want to stick to, and also the naming modernized sticks out a lot to me.

Comment thread src/elements/content-uploader/ContentUploader.tsx
@dealwith dealwith force-pushed the implement-cancel-all-retry-all-handlers branch 2 times, most recently from 4b36707 to 330c734 Compare May 28, 2026 12:40
@dealwith dealwith requested a review from jpan-box May 28, 2026 13:58
Base automatically changed from integrate-shared-feature-into-content-uploader to master May 28, 2026 15:04
@mergify mergify Bot dismissed olehrybak’s stale review May 28, 2026 15:04

The base branch was changed.

jpan-box
jpan-box previously approved these changes May 28, 2026
Copy link
Copy Markdown
Collaborator

@jpan-box jpan-box left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All addressed — thanks for the clean refactor commit. Naming, shared retry helper, VRT cleanup, and constant alignment all look good.

…handlers

- Restore typeof STATUS_* union, add STATUS_CANCELED to keep type/constant linked
- Rename handleModernized* -> handleUploadsManager* for clarity
- Extract retryUploadsManagerItem helper shared by RetryAll and per-item retry
- Drop unreachable empty-cancelable guard in handleUploadsManagerCancelAll
- Drop dead typeof api.cancel function check in markItemCanceled
- Align item handlers to warn-and-return on missing key
- Replace inline status strings with constants in tests
- Remove modernized VRTs already covered by shared feature tests
@dealwith dealwith force-pushed the implement-cancel-all-retry-all-handlers branch from 843f559 to 7947462 Compare May 28, 2026 15:54
jpan-box
jpan-box previously approved these changes May 28, 2026
Copy link
Copy Markdown
Collaborator

@jpan-box jpan-box left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approving after rebase.

dlasecki-box
dlasecki-box previously approved these changes May 28, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/elements/content-uploader/ContentUploader.tsx`:
- Around line 1188-1196: handleUploadsManagerCancelAll currently bulk-cancels
items then calls updateViewAndCollection, but the collection-status predicates
still treat canceled items as "in progress", leaving queues stuck in
VIEW_UPLOAD_IN_PROGRESS; update the collection-status derivation used by
updateViewAndCollection (and any helper like areAllItemsFinished) to treat
STATUS_CANCELED as a terminal/finished state (i.e., exclude STATUS_CANCELED from
in-progress checks and include it as finished for areAllItemsFinished), so after
markItemCanceled the view correctly transitions out of VIEW_UPLOAD_IN_PROGRESS.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9d2ac303-e95f-4d62-aadc-b179ebb574b0

📥 Commits

Reviewing files that changed from the base of the PR and between 5b10535 and 7947462.

⛔ Files ignored due to path filters (1)
  • i18n/en-US.properties is excluded by !i18n/**
📒 Files selected for processing (6)
  • src/common/types/upload.js
  • src/constants.js
  • src/elements/content-uploader/ContentUploader.tsx
  • src/elements/content-uploader/__tests__/ContentUploader.test.js
  • src/elements/content-uploader/utils/__tests__/mapToModernizedUploadItem.test.ts
  • src/elements/content-uploader/utils/mapToModernizedUploadItem.ts

Comment thread src/elements/content-uploader/ContentUploader.tsx
These keys had no defineMessages source on this branch, so the CI
i18n rebuild dropped them and failed the generated-files check.
@dealwith dealwith dismissed stale reviews from dlasecki-box and jpan-box via 514e1b1 May 28, 2026 16:14
@mergify mergify Bot added the queued label May 28, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 28, 2026

Merge Queue Status

  • Entered queue2026-05-28 17:11 UTC · Rule: Automatic strict merge
  • Checks passed · in-place
  • Merged2026-05-28 17:24 UTC · at e4fc5f8e311c5e8d1607666e7e2a73155d06d711 · squash

This pull request spent 13 minutes 8 seconds in the queue, including 12 minutes 23 seconds running CI.

Required conditions to merge

@mergify mergify Bot merged commit 10ecc34 into master May 28, 2026
13 checks passed
@mergify mergify Bot deleted the implement-cancel-all-retry-all-handlers branch May 28, 2026 17:24
@mergify mergify Bot removed the queued label May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants